package io;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

public class OutputStreamDemo4 {
    public static void main(String[] args) throws IOException {

        File file=new File("mytest.txt");
        if(!file.exists()){
            file.createNewFile();
        }
        try(PrintWriter printWriter=new PrintWriter(file)){
            printWriter.println("这是第一行数据");
            printWriter.println("这是第二行数据");
            printWriter.printf("我叫：%s,今年：%d,有男朋友","雪",21);
            printWriter.flush();
        }
    }
}
